<!DOCTYPE html>  <!--文档声明-->
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">  <!--英文的编码状态-->
<head th:replace="theme/default/common :: head(~{::title})">  <!--不可见内容-->
    <meta charset="UTF-8">  <!--编码格式-->
    <meta name="viewport" content="width=device-width,initial-scale=1.0"><!--适配手机浏览-->
    <title th:text="|${blog.title} - ${webname} - 从前的日子很慢，车马邮件都很慢，一生只够爱一个人|"></title>   <!--标题-->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css"><!--引入css样式-->
    <link rel="stylesheet" href="../../../static/css/typo.css">
    <link rel="stylesheet" href="../../../static/css/animate.css">
    <link rel="stylesheet" href="../../../static/css/me.css">
    <link rel="stylesheet" href="../../../static/lib/prism/prism.css">
    <link rel="stylesheet" href="../../../static/lib/tocbot/tocbot.css">
    <link rel="stylesheet" href="../../../static/lib/aplayer/APlayer.min.css">
    <style type="text/css">
        .blink {
            position: relative;
        }

        .blink:nth-child(1) {
            -webkit-animation: jump 1s linear 0s infinite alternate;
        }

        @-webkit-keyframes jump {
            0% {
                top: 0px;
            }
            50% {
                top: -2px;
            }
            100% {
                top: 3px;
            }
        }

    </style>
</head>
<!--内容编写区-->
<body>
<!--背景-->
<canvas id="evanyou" width="1920" height="934"></canvas>
<!--导航-->
<nav th:replace="theme/default/common :: menu(1)" class="ui attached segment m-padded-tb-mini animated bounce">
    <div class="ui container">
        <div class="ui secondary stackable menu">
            <h2 class="ui black header item">三岁Blog</h2>
            <a href="#" class="m-item item m-mobile-hide-item"><i class="mini home icon"></i>&nbsp&nbsp首页</a>
            <span class="m-mobile-hide" style="width: 1px;margin-top: 20px;height: 20px; background: darkgray;"></span>
            <a href="#" class="m-item item m-mobile-hide-item"><i class="mini idea icon"></i>&nbsp&nbsp分类</a>
            <span class="m-mobile-hide" style="width: 1px;margin-top: 20px;height: 20px; background: darkgray;"></span>
            <a href="#" class="m-item item m-mobile-hide-item"><i class="mini tags icon"></i>&nbsp&nbsp标签</a>
            <span class="m-mobile-hide" style="width: 1px;margin-top: 20px;height: 20px; background: darkgray;"></span>
            <a href="#" class="m-item item m-mobile-hide-item"><i class="mini clone icon"></i>&nbsp&nbsp归档</a>
            <span class="m-mobile-hide" style="width: 1px;margin-top: 20px;height: 20px; background: darkgray;"></span>
            <span class="m-item item m-mobile-hide">
            <iframe scrolling="no" src="https://tianqiapi.com/api.php?style=tv&skin=durian" frameborder="0" width="255"
                    height="25" allowtransparency="true"></iframe>
            </span>
            <div class="m-item right item m-mobile-hide-item">
                <div class="ui icon inverted input"><!--transparent 属性是设置全透明黑色-->
                    <input type="text" placeholder="输入关键词搜索...">
                    <i class="search link icon"></i>
                </div>
            </div>
        </div>
    </div>
    <a href="#" class="ui menu toggle basic black icon button m-right-top m-mobile-show">
        <i class="sidebar icon"></i>
    </a>
</nav>
<!--中间内容-->
<div id="waypoint" class="m-container-small m-padded-tb-big animated fadeIn">
    <div class="ui container">
        <!--头部内容-->
        <div class="ui top attached segment">
            <div class="ui horizontal link list">
                <div class="item">
                    <img src="http://q1.qlogo.cn/g?b=qq&nk=1578393930&s=100"
                         th:src="@{${blog.description}}"
                         alt="图片正在路上..." class="ui avatar image">
                    <div class="content"><a href="#" class="header" th:text="${blog.createUser}">三岁</a></div>
                </div>
                <div class="item">
                    <i class="calendar alternate outline icon"></i>
                    <span th:text="${#dates.format(blog.updateTime,'yyyy-MM-dd HH:mm:ss')}">2020-02-17</span>
                </div>
                <div class="item">
                    <i class="eye icon"></i>&nbsp&nbsp
                    <span th:text="${blog.views}">123</span>
                </div>
            </div>
        </div>
        <!--内容区域-->
        <div class="ui attached padded segment">
            <div class="ui right aligned basic segment">
                <div class="ui orange basic label" th:text="${blog.sourceFlag==0?'原创':'转载'}">原创</div>
            </div>
            <h2 class="ui center aligned header" th:text="${blog.title}">超级暖心睡前爱情小故事</h2><br>
            <div id="content" class="typo typo-selection js-toc-content m-padded-lr-reponsive m-padded-tb-large"
                 th:utext="${blog.content}">


            </div>
            <!--标签-->
            <div class="m-padded-lr-reponsive">
                <!--<div class="ui basic teal left pointing label">小故事</div>--><!--尖角在左边-->
                <div class="ui basic teal pointing label" th:text="${blog.tagsId}">小故事</div><!--尖角在上边-->
            </div>
            <!--打赏-->
            <div class="ui center aligned basic segment" th:if="${blog.appreciation}">
                <button id="payButton" class="ui orange basic circular button">赞赏</button>
            </div>
            <div class="ui payQR flowing popup transition hidden">
                <div class="ui orange basic label">
                    <div class="ui images" style="font-size: inherit !important;">
                        <div class="m-padded-tb">觉得文章有用就打赏一下文章作者</div>
                        <div class="image">
                            <img src="../../../static/images/zfb.jpg" th:src="@{/images/zfb.jpg}" alt=""
                                 class="ui rounded bordered image" style="width: 120px">
                            <div>支付宝扫一扫打赏</div>
                        </div>
                        <div class="image">
                            <img src="../../../static/images/wx.jpg" th:src="@{/images/wx.jpg}" alt=""
                                 class="ui rounded bordered image" style="width: 120px">
                            <div>微信扫一扫打赏</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!--博客信息-->
        <div class="ui attached positive message" th:if="${blog.shareStatement}">
            <div class="ui middle aligned grid">
                <div class="eleven wide column">
                    <ui class="list">
                        <li>本文作者：<span th:text="${blog.createUser}">三岁</span></li>
                        <li>本文链接：<span id="local-url"></span></li>
                        <li>发表时间：<span th:text="${#dates.format(blog.createTime,'yyyy-MM-dd HH:mm:ss')}">2020-01-01 00:00</span>
                        </li>
                        <li>版权声明：本博客所有文章除特别声明外，均采用 BY-NC-SA 许可协议。转载请注明出处！</li>
                        <li>公众号转载：请在文末添加作者公众号二维码</li>
                        <li>声援博主：如果您觉得文章对您有帮助，可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力！</li>
                    </ui>
                </div>
                <div class="five wide column">
                    <img src="./static/images/ewm.png" th:src="@{/images/ewm.png}" alt=""
                         class="ui right floated rounded bordered image" style="width: 110px">
                </div>
            </div>
        </div>
        <!--留言区域-->
        <div class="ui bottom attached segment" th:if="${blog.commentabled}">

            <div id="comment-form" class="ui form">
                <h3 class="ui dividing header" style="color: #FF6666;font-weight: 600;" >添加新评论</h3>
                <input type="hidden" name="blogId" th:value="${blog.blogId}">
                <input type="hidden" name="parentComment.id" value="-1">
                <div class="field">
                    <textarea name="comment" placeholder="你的评论可以一针见血..."></textarea>
                </div>
                <div class="fields">
                    <div class="field m-mobile-wide m-margin-bottom-small">
                        <div class="ui icon input">
                            <img class="ui avatar middle aligned mini image" id="commentavatar"
                                 src="./static/images/avatar.svg" th:src="${session.user}!=null?@{${userInfo.avatars}}:@{/images/avatar.svg}">
                            <input type="text" name="qq" id="commentQQ" th:id="${session.user}!=null?'':'commentQQ'" th:value="${session.user}!=null ? ${userInfo.qq}" placeholder="*填写QQ号获取头像和昵称">
                        </div>
                    </div>
                    <div class="field m-mobile-wide m-margin-bottom-small">
                        <div class="ui left icon input input-nickname">
                            <i class="user icon user-icon"></i>
                            <i class="search icon search-icon" style="display: none"></i>
                            <input type="text" name="nickname" th:value="${session.user}!=null ? ${userInfo.nickname}" placeholder="*昵称">
                        </div>
                    </div>
                    <div class="field m-mobile-wide m-margin-bottom-small">
                        <div class="ui left icon input input-email">
                            <i class="mail icon mail-icon"></i>
                            <i class="search icon search-icon" style="display: none"></i>
                            <input type="email" name="email" th:value="${session.user}!=null ? ${userInfo.email}" placeholder="邮箱">
                        </div>
                    </div>
                    <div class="field m-mobile-wide m-margin-bottom-small">
                        <button id="commentpost-btn" type="submit" class="ui black button m-mobile-wide"><i
                                class="edit icon"></i>提交
                        </button>
                    </div>
                </div>
            </div>

            <div id="comment-container" class="ui teal segment">
                <div th:fragment="commentList">
                    <div class="ui threaded comments">
                        <h3 class="ui dividing header" style="font-weight: 500;">
                             已经有 <span th:text="${commentNum}">88</span> 条评论
                        </h3>
                        <div class="comment" th:each="comment : ${comments}">
                            <a class="avatar" th:id="'comment-'+${comment.commentid}">
                                <img src="https://unsplash.it/100/100?image=1005" th:src="@{${comment.avatar}}">
                            </a>
                            <div class="content">
                                <a class="author">
                                    <span th:text="${comment.nickname}">Matt</span>
                                    <div class="ui black m-padded-mini label"
                                         th:if="${comment.admincomment}">博主
                                    </div>
                                </a>
                                <div class="metadata">
                                    <span class="date"
                                          th:text="${#dates.format(comment.createtime,'yyyy-MM-dd HH:mm')}">Today at 5:42PM</span>
                                    <span class="date">
                                                <i class="map marker alternate icon"></i>
                                                来自 <span th:text="${comment.sourcecity}">火星</span></span>
                                </div>
                                <div class="text" th:text="${comment.comment}">
                                    How artistic!
                                </div>
                                <div class="actions">
                                    <a class="reply" style="color:#1E90FF" data-commentid="1"
                                       data-commentnickname="sansui"
                                       th:attr="data-commentid=${comment.commentid},data-commentnickname=${comment.nickname}"
                                       onclick="reply(this)">回复</a>
                                </div>
                            </div>


                            <div class="comments" th:if="${#arrays.length(comment.replyComments)}>0">
                                <div class="comment" th:each="reply : ${comment.replyComments}">
                                    <a class="avatar" th:id="'comment-'+${reply.commentid}">
                                        <img src="../static/images/avatar.png" th:src="@{${reply.avatar}}">
                                    </a>
                                    <div class="content">
                                        <a class="author">
                                            <span th:text="${reply.nickname}">小白</span>
                                            <div class="ui black m-padded-mini label"
                                                 th:if="${reply.admincomment}">博主
                                            </div>
                                            &nbsp;<span th:text="|@ ${reply.parentnickname}|" style="color: #1E90FF;" class="m-teal">@ 小红</span>
                                            <div class="ui black m-padded-mini label"
                                                 th:if="${reply.admincomment}">博主
                                            </div>
                                        </a>
                                        <div class="metadata">
                                            <span class="date"
                                                  th:text="${#dates.format(reply.createtime,'yyyy-MM-dd HH:mm')}">Today at 5:42PM</span>
                                            <span class="date">
                                                <i class="map marker alternate icon"></i>
                                                来自 <span th:text="${reply.sourcecity}">火星</span></span>
                                        </div>
                                        <div class="text" th:text="${reply.comment}">
                                            你也是！
                                        </div>
                                        <div class="actions">
                                            <a class="reply" style="color:#1E90FF" data-commentid="1"
                                               data-commentnickname="Matt"
                                               th:attr="data-commentid=${reply.commentid},data-commentnickname=${reply.nickname}"
                                               onclick="reply(this)">回复</a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>

<div id="toolbar" class="m-fixed m-right-bottom m-padded-big" style="display: none">
    <div class="ui vertical icon buttons">
        <button type="button" class="ui toc teal button">目录</button>
        <a href="#comment-form" class="ui teal button">评论</a>
        <button class="ui icon button wechat m-mobile-hide"><i class="weixin icon"></i></button>
        <div id="totop-button" class="ui icon button"><i class="chevron up icon"></i></div>

        <div id="qrcode" class="ui wechatQR flowing popup transition hidden " style="width: 120px !important;">
            <div class="item">手机扫码查看</div>

        </div>
    </div>
</div>

<div class="ui toc-container flowing popup transition hidden" style="width: 250px !important;">
    <ol class="js-toc">

    </ol>
</div>


<!--音乐播放器-->
<div th:replace="theme/default/common :: aplayer"></div>
<!--底部footer-->
<footer th:replace="theme/default/common :: footer" class="ui inverted vertical segment footer-bj">
    <div class="ui center aligned container m-text-lined">
        <div class="m-text-thin m-text-spaced m-opacity-mini">【事实并非理所当然<span class="blink">❤️</span>世界总是欲盖弥彰】</div>
        <div class="m-text-thin m-text-spaced m-opacity-mini">本站勉强运行:<span id="runtime_span"
                                                                           style="color: #24a0f0;"></span></div>
        <div class="m-text-thin m-text-spaced m-opacity-mini">友情链接：<a href="#">申请坑位</a>/<a href="#">申请坑位</a>/<a
                href="#">申请坑位</a></div>
        <div class="ui inverted  divider"></div>
        <p class="m-text-thin m-text-spaced m-opacity-tiny">Copyright © 2016 - 2022 Designed by sansui</p>
    </div>
</footer>

<!--/*/<th:block th:replace="theme/default/common :: script">/*/-->
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script><!--引入jquery js-->
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script><!--引入semantic的js-->
<script src="https://cdn.jsdelivr.net/npm/jquery.scrollto@2.1.2/jquery.scrollTo.min.js"></script>
<script type="text/javascript" color="54,54,54" opacity='0.7' zIndex="-2" count="99"
        src="https://cdn.bootcss.com/canvas-nest.js/1.0.1/canvas-nest.min.js"></script><!--背景-->
<script src="../../../static/lib/prism/prism.js"></script>
<script src="../../../static/lib/tocbot/tocbot.min.js"></script>
<script src="../../../static/lib/qrcode/qrcode.min.js"></script>
<script src="../../../static/lib/waypoints/jquery.waypoints.min.js"></script>
<script src="../../../static/lib/aplayer/APlayer.min.js"></script>
<script src="../../../static/lib/aplayer/Meting.min.js"></script>
<script src="../../../static/js/me.js"></script>
<!--/*/</th:block>/*/-->

<script type="text/javascript">

    $('#payButton').popup({
        popup: $('.payQR.popup'),
        on: 'click',
        position: 'bottom center'
    });

    tocbot.init({
        // Where to render the table of contents.
        tocSelector: '.js-toc',
        // Where to grab the headings to build the table of contents.
        contentSelector: '.js-toc-content',
        // Which headings to grab inside of the contentSelector element.
        headingSelector: 'h1, h2, h3',
    });

    $('.toc.button').popup({
        popup: $('.toc-container.popup'),
        on: 'click',
        position: 'left center'
    });

    $('.wechat').popup({
        popup: $('.wechatQR'),
        on: 'click',
        position: 'left center'
    });

    var url = window.location.href; /* 获取完整URL */
    $("#local-url").text(url)
    var qrcode = new QRCode("qrcode", {
        text: "" + url + "",
        width: 110,
        height: 110,
        colorDark: "#000000",
        colorLight: "#ffffff",
        correctLevel: QRCode.CorrectLevel.H
    });

    $(function () {
        $("#comment-container").load("[[@{/blogs/comments/{blogId}(blogId=${blog.blogId})}]]");
    });

    $("#commentQQ").blur(function () {
        if ($("#commentQQ").val() == '' || $("#commentQQ").val() == null) {
        } else {
            $(".input-nickname").attr("class", "ui left icon input loading input-nickname");
            $(".input-email").attr("class", "ui left icon input loading input-email");
            $(".search-icon").attr("style", "");
            $(".user-icon").attr("style", "display:none");
            $(".mail-icon").attr("style", "display:none");
            $("input[name='nickname']").attr("disabled", "");
            $("input[name='email']").attr("disabled", "");

            $.ajax({
                url: '/blogs/getAvatar',
                type: 'post',
                data: {'qq': $("#commentQQ").val()},
                success: function (suc) {
                    // console.log(suc)
                    if (suc.code == 200) {
                        $("#commentavatar").val(suc.data.imgurl);
                        $("#commentavatar").attr("src", suc.data.imgurl);
                        $("input[name='nickname']").val(suc.data.name);
                        $("input[name='email']").val(suc.data.qemail);

                        $(".input-nickname").attr("class", "ui left icon input input-nickname");
                        $(".input-email").attr("class", "ui left icon input input-email");
                        $(".search-icon").attr("style", "display:none");
                        $(".user-icon").attr("style", "");
                        $(".mail-icon").attr("style", "");
                        $("input[name='nickname']").removeAttr("disabled");
                        $("input[name='email']").removeAttr("disabled");
                    }
                }, error(jqXHR, textStatus, errorThrown) {
                    // 错误信息处理
                    console.error(textStatus, errorThrown)
                }
            });
        }
    });

    //评论表单验证
    $('.ui.form').form({
        fields: {
            title: {
                identifier: 'comment',
                rules: [{
                    type: 'empty',
                    prompt: '请输入评论内容'
                }
                ]
            },
            content: {
                identifier: 'nickname',
                rules: [{
                    type: 'empty',
                    prompt: '请输入你的大名'
                }]
            },
            type: {
                identifier: 'email',
                rules: [{
                    type: 'email',
                    prompt: '请填写正确的邮箱地址'
                }]
            }
        }
    });

    //校验
    $('#commentpost-btn').click(function () {
        var bool = $('.ui.form').form('validate form');
        if (bool) {
            console.log('校验成功');
            $("#commentpost-btn").attr("disabled", "");
            postData();
        } else {
            console.log('校验失败');
        }
    });

    function postData() {
        $("#comment-container").load("[[@{/blogs/comments}]]", {
            "parentcommentid": $("[name='parentComment.id']").val(),
            "blogId": $("[name='blogId']").val(),
            "qq": $("#commentQQ").val(),
            "nickname": $("input[name='nickname']").val(),
            "email": $("input[name='email']").val(),
            "avatar": $("#commentavatar").val(),
            "comment": $("[name='comment']").val()
        }, function (responseTxt, statusTxt, xhr) {
            console.log(xhr)

            $("#commentpost-btn").removeAttr("disabled");
            if($("[name='parentComment.id']").val()>-1){
                $(window).scrollTo($("#comment-"+$("[name='parentComment.id']").val()), 500);
                let n = $("[name='parentComment.id']").val();
                $("#comment-"+n).transition('tada');
            }else{
                $(window).scrollTo($("#comment-container"), 500);
            }
            clearContent();
        })
    }

    function clearContent() {
        $("[name='comment']").val('');
        $("[name='parentComment.id']").val(-1);
        $("[name='comment']").attr("placeholder", "你的评论可以一针见血...");
    }

    function reply(obj) {
        var commentId = $(obj).data("commentid");
        var commentName = $(obj).data("commentnickname");
        $("[name='comment']").attr("placeholder", "@" + commentName).focus();
        $("[name='parentComment.id']").val(commentId);
        $(window).scrollTo($("#comment-form"), 500);
    }


</script>

</body>
</html>